import random
from optparse import OptionParser

def readFile(filename):
	"""Given a filename, read the contents of that file.
	"""
	f = open(filename)
	line = ''
	book = []

	while 1==1:
		line = f.readline()
		if line != '':
			if line != '\n':
				book.append(line)
		else:
			break
	f.close()
	return book

if __name__=='__main__':
	parser = OptionParser()
	parser.add_option("-b", "--book", dest = "book", default="cthullu.txt", help = "The name of the file you'd like to have read in.", metavar="BOOK.txt")
	parser.add_option("-p", "--paragraphs", dest = "paragraphs", default=1, help = "The number of paragraphs you'd like to generate.", metavar="#")
	opts = parser.parse_args()
	options = opts[0]

book = readFile(options.book)
options.paragraphs = int(options.paragraphs)
for i in range (options.paragraphs):
	print book[random.randrange(0,len(book))]

